<?php

/**
 * level actions.
 *
 * @package    elearning
 * @subpackage level
 * @author     Dvquan
 * @version		1.00.00
 * @Created		09.08.2010
 * @Update
 */
class levelActions extends sfActions
{
  public function executeIndex(sfWebRequest $request)
  {
	$lang_current = sfContext::getInstance()->getUser()->getCulture();
    //$this->level_list = LevelPeer::doSelect(new Criteria());
	$actionPage = $this->getRequestParameter('page', 1);
	$this->pager =  LevelPeer::getListLevelWithCourse( $request->getParameter('courseid',0), $lang_current, $actionPage, 10 );
	$this->rows = $this->pager->getResults();
	$this->coursename = LevelPeer::getCourseNamebyCourseId($request->getParameter('courseid',0), $lang_current);
  }

  public function executeShow(sfWebRequest $request)
  {
	//getListLevelByprimary
	$lang_current = sfContext::getInstance()->getUser()->getCulture();
    $this->level = LevelPeer::getListLevelByprimary($request->getParameter('id'));
    $this->forward404Unless($this->level);
	//get classes with level
	$this->classes = LevelPeer::getClassesWithLevel( $request->getParameter('id') );
	$this->coursename = LevelPeer::getCourseNamebyCourseId($request->getParameter('courseid',1), $lang_current);
	
  }
/*
  public function executeNew(sfWebRequest $request)
  {
    $this->form = new LevelForm();
  }

  public function executeCreate(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod('post'));

    $this->form = new LevelForm();

    $this->processForm($request, $this->form);

    $this->setTemplate('new');
  }

  public function executeEdit(sfWebRequest $request)
  {
    $this->forward404Unless($level = LevelPeer::retrieveByPk($request->getParameter('id')), sprintf('Object level does not exist (%s).', $request->getParameter('id')));
    $this->form = new LevelForm($level);
  }

  public function executeUpdate(sfWebRequest $request)
  {
    $this->forward404Unless($request->isMethod('post') || $request->isMethod('put'));
    $this->forward404Unless($level = LevelPeer::retrieveByPk($request->getParameter('id')), sprintf('Object level does not exist (%s).', $request->getParameter('id')));
    $this->form = new LevelForm($level);

    $this->processForm($request, $this->form);

    $this->setTemplate('edit');
  }

  public function executeDelete(sfWebRequest $request)
  {
    $request->checkCSRFProtection();

    $this->forward404Unless($level = LevelPeer::retrieveByPk($request->getParameter('id')), sprintf('Object level does not exist (%s).', $request->getParameter('id')));
    $level->delete();

    $this->redirect('level/index');
  }

  protected function processForm(sfWebRequest $request, sfForm $form)
  {
    $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
    if ($form->isValid())
    {
      $level = $form->save();

      $this->redirect('level/edit?id='.$level->getId());
    }
  }
  */
}
